package view;

import geometricElement.GeometricElement;

import java.util.LinkedList;

import robot.Robot;

public class SystemIO implements View {

	// members
	String askForOption = "Please insert 1 to place new robots on the ground, 2 to place new elements or 3 to start the pick up\n";
	String askForType = "Please insert type. Possible types: Circle, Square, PerfectTriangle\n";			
	String askForXcord = "Please insert x axis coordinate\n"; 
	String askForYcord = "Please insert y axis coordinate\n";
	String askForProperty = "Please insert property. Circle's property is radius, Square / PerfectTriangle's property is side length\n";

	// methods
	public int[] getGroundSize() {
		int[] size = new int[2];
		size[0] = Console.readInt("Please enter ground's height\n");
		size[1] = Console.readInt("Please enter ground's width\n");
		return size;
	}
	
	/**
	 * Asks the user for wanted option and returns it
	 * @return Option given by user
	 */
	public int getOption() {
		return Console.readInt(askForOption);
	}
	
	public double getRobotBasket() {
		return Console.readDouble("Please enter basket capacity for the robot\n");
	}
	
	/**
	 * Prints message to ask the 
	 * @return New object's type 
	 */
	public String getObjectType() {
		return Console.readString(askForType);
	}
	
	/**
	 * Prints message to ask the user for the new object's type
	 * @return New object's property
	 */
	public double getObjectProperty() {
		return Console.readDouble(askForProperty);
	}
	
	/**
	 * Asks the user for wanted position (x and y coordinates) for the new object.
	 * Returns an array of 2 ints- the first entry is x-axis coordinate and the second is y-axis coordinate 
	 * @return Int array of size 2, holding the position
	 */
	public int[] getObjectPosition() {
		int[] position = new int[2];
		position[0] = Console.readInt(askForXcord);
		position[1] = Console.readInt(askForYcord);
		return position;
	}
	
	public int askIfContinue(String type) {
		return Console.readInt(String.format("If you want to add any more %ss, insert 1. Otherwise, 0.\n", type));
	}
	
	/**
	 * Prints error given message to the user
	 * @param msg- Error message to be printed
	 */
	public void notifyErrorMsg(String msg) {
		System.out.println(msg);
	}

	// TODO 
	public void printNonPickedGeoElements(LinkedList<GeometricElement> listToPrint) {
		if (listToPrint.isEmpty()) {
			System.out.println("All geometric elements were picked up :)");
			return;
		}
		System.out.println("Could not pick up the following geomteric elements:");
		for (GeometricElement currElement : listToPrint) {
			System.out.println(currElement);
		}
		return;
	}
	// TODO
	public void printRobotsStats(LinkedList<Robot> listToPrint) {
		
		if (listToPrint.isEmpty()) {
			System.out.println("Cannot print statistics since no robots were created.");
			return;
		}		
		
		System.out.println("Printing robots' statistics:");
		for (Robot currRobot : listToPrint) {
			System.out.println(currRobot);
		}
	}
}
